package com.refusea.train.mapper

import com.refusea.train.domain.entity.LessonScheduleConfig
import org.apache.ibatis.annotations.Insert
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.annotations.Update

/**
 * @author Zhang Yan 2024/4/10
 **/
@Mapper
interface LessonScheduleConfigMapper {

    @Select("SELECT * FROM lesson_schedule_config WHERE school_id = #{schoolId}")
    fun select(schoolId: Int): LessonScheduleConfig?

    @Insert(
        """
        INSERT INTO lesson_schedule_config 
        (school_id, workday_hour, holiday_hour, half_hour) 
        VALUES 
        (#{schoolId}, #{workdayHour}, #{holidayHour}, #{halfHour})
        """
    )
    fun insert(lessonScheduleConfig: LessonScheduleConfig): Int

    @Update(
        """
        UPDATE lesson_schedule_config 
        SET workday_hour = #{workdayHour}, holiday_hour = #{holidayHour}, half_hour = #{halfHour}
        WHERE id = #{id} and school_id = #{schoolId}
        """
    )
    fun update(lessonScheduleConfig: LessonScheduleConfig): Int

}
